package com.tydic.feignconsumer.controller;

import com.tydic.feignconsumer.service.HelloService;
import com.tydic.feignconsumer.service.RefactorHelloService;
import com.tydic.helloserviceapi.domain.Goods;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @Description: 跨服务调用
 * @Author: xuwenguang
 * @CreateDate: 2019/3/6 11:15
 * @UpdateUser: xuwenguang
 * @UpdateDate: 2019/3/6 11:15
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@RestController
public class FeignController {
//    @Resource
//    private HelloService helloService;
    @Resource
    private RefactorHelloService refactorHelloService;
//    @RequestMapping(value = "/feign-consumer",method = {RequestMethod.GET})
//    public String feignConsumer(){
//        return helloService.hello();
//    }
    @RequestMapping(value = "/",method = {RequestMethod.GET})
    public String healthCheck(){
        return "hello consul";
    }

    @RequestMapping(value="/feign-consumer3",method={RequestMethod.GET})
    public String helloConsumer3(){
        StringBuilder sb=new StringBuilder();
        sb.append(refactorHelloService.hello("box")).append("\n");
        //sb.append(refactorHelloService.hello(new Goods("phone",new BigDecimal(20))));
        return sb.toString();
    }

    @RequestMapping(value="/feign-consumer5",method={RequestMethod.GET})
    public String helloConsumer5(){
        StringBuilder sb=new StringBuilder();
        Goods goods=new Goods();
        goods.setName("phone");
        goods.setPrice(new BigDecimal(20));
        sb.append(refactorHelloService.hello(goods));
        return sb.toString();
    }
}
